<?php 
	echo $this->inlineScript()->setScript('$(document).ready(function(){
		$("#from").datepicker({ dateFormat: "yy-mm-dd" });
		$("#to").datepicker({ dateFormat: "yy-mm-dd" });
	})');
?>
<form id="formrap" method="post" action="">
	<input type="hidden" id="excel" name="excel" value="0" />
	<table cellspacing="1" cellpadding="6" class="tlist">
		<tr>
			<td>
				Od: <?php echo $this->formText( 'from', $this->from ); ?>
			</td>
			<td>
				Do: <?php echo $this->formText( 'to', $this->to ); ?>
			</td>
			<td>
				<a onclick="$('#formrap').find('#excel').val( 0 );$('#formrap').submit()" class="button" href="javascript::void(null)">
					<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/plus_16.png);" class="inb">Generuj raport na ekran</div>
				</a>
			</td>
			<td>
				<a onclick="$('#formrap').find('#excel').val( 1 );$('#formrap').submit()" class="button" href="javascript::void(null)">
					<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/gear_16.png);" class="inb">Generuj raport do Excel</div>
				</a>
			</td>
			<td>
				<a class="button" href="<?php echo $this->baseUrl() ?>/cpusers/list/type/2">
					<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/left_16.png);" class="inb">Wróć do listy</div>
				</a>
			</td>
		</tr>
	</table>
</form>
<div class="bglist">
	<div class="bglistq">
		
		<?php if( count( $this->raportList ) ) { ?>
			
			<table cellspacing="1" cellpadding="6" class="tlist">
				<tr>
					<th>Nr. transakcji</th>
					<th>Klient</th>
					<th>Data</th>
					<th>Kwota prowizji</th>
				</tr>
				<?php 
				$sum = 0;
				foreach( $this->raportList as $item ) { ?>
				<tr>
					<td><?php echo $item['o_id'] ?></td>
					<td><?php 
					echo $item['Users']['name'] . ' ' . $item['Users']['surname'] . '<br />';
					echo $item['Users']['email'] 
					?></td>
					<td><?php echo $item['add_date'] ?></td>
					<td><?php 
						$sum = $sum + number_format( $item['provision'], 2, '.', '' );
						echo number_format( $item['provision'], 2, '.', ' ' ) . ' ' . $item['currency'] . ' netto';
					?></td>
				</tr>
				<?php } ?>
			</table>
		<?php } else { ?>
			<table cellspacing="1" cellpadding="6" class="tlist">
				<tr>
					<th>Nr. transakcji</th>
					<th>Klient</th>
					<th>Data</th>
					<th>Kwota prowizji</th>
				</tr>
				<tr>
					<td colspan="4">brak rekordów spełniajacych kryteria</td>
				</tr>
			</table>
		<?php } ?>
	</div>
</div>